Application note: The CFS2/FS2002 texture allocation system

The CFS2/FS2002 MDL file format provides the aircraft designer with much more flexibility in texture handling. As it happens very often too much flexibility confuses the end user. Here is a short presentation of the texture allocation system implemented by FS2002.

All the textures used in an assembly must be declared in a texture list. CFS2/FS2002 supports different formats, ranging from the very basic bitmap format to the complex DXT3 multi-size format. Except for the standard bitmap format, these formats allows for alpha effects or transparency (colorkey attribute). The alpha parameter can be used either for alpha blending or to create a specular effect. In case the texturing mode is inhibited or the texture file can't be found, FS uses a so-called fallback color which is defined by its red, blue, green and alpha attributes. Each texture can be assigned a different fallback color.

A sub-assy may be textured or colored. When it is colored, a sub-assy can be given a certain level of transparency and a glaring effect. Color, transparency index and glaring effect are handled through the material concept. When it is textured, a sub-assy is assigned one of the declared assembly textures (see here above). Of course, a texture can be assigned to different sub-assies. Each sub-assy / texture set is associated with a material, the color of which can be different from the texture fallback color. A sub-assy can be declared as a no-shadow thing, a usefull feature if you don't want to see a plain shadow associated with a canopy or the transparent disk modelling a propeller at full speed.

Textures and materials

The FS viewer uses the DirectX standard to display objects on your computer screen. The DirectX standard handles the colors and the illumination of an object through two concepts:

  • the material concept,
  • the texture mapping.
Materials
Let us take a sub-assy. To make it simple, you can consider that this sub-assy is a bulk of material. The characteristics of a material are:
  • its color,
  • its transparency index,
  • whether it glares or not,
  • the reflected color if it glares.
A transparent material casts no shadow on the ground.

You can use this sub-assy as it is: a piece of raw material. In that case, you just have to specify the material of which it is made up. The color sub-panel at the bottom of the sub-assy code display window allows you to do that.


the color sub-panel

Textures
Most of the time, you do not use raw sub-assies. As it is in the real world, you want to ornate them, or you want to model tiny details by drawing them on the surface of the sub-assies. You can do that by mapping textures on the sub-assies. The mapping texture process is described later on in this tutorial.


the texture support selection window

The FS viewer supports several kind of textures: simple bitmap files, DXT files, mipmaps... AD2K2 handles a restricted sub-set of formats the characteristics of which are given here after:

  • 64x64, 128x128, 256x256, 512x512 and 1024x1024 pictures,
  • original BMP files,
  • DXT1 and DXT3 files,
  • mipmaps.
Texture attribute
When it is loaded into the texture list, a texture must be given an attribute:
  • normal,
  • specular,
  • night map,
  • light map.
The texture attribute must be used cautiously. The normal and specular textures are the only textures that you should assign to a sub-assy. To yield a specular effect, a specular texture must have an alpha layer. The night map textures and the light map textures should be considered as masks to be superimposed over a basic texture (a normal one or a specular one).

Let us have a look at the following example. I suppose we plan to use seven texture files:

  • Wheel.bmp is a basic texture to be used under any conditions.
  • Wing.bmp is a texture to be used under any conditions, it features an alpha layer to model a specular effect.
  • Fuse.bmp is a day-time texture featuring an alpha layer to model a specular effect. At night, it is to be replaced by Fuse_nm.bmp. When the aircraft lights are ON, Fuse_lm.bmp should take over.
  • Nose.bmp is a day-time texture featuring an alpha layer to model holes. At night, it is to be replaced by Nose_nm.bmp.
These textures must be declared in the following order:

A
 Wheel.bmp
S
 Wing.bmp
S
 Fuse.bmp
N
 Fuse_nm.bmp
L
 Fuse_lm.bmp
A
 Nose.bmp
N
 Nose_nm.bmp

Indeed, when you assign a texture to a sub-assy, the FS viewer browses the texture list to check the attribute of the textures immediately following the selected texture. Therefore, the list here above is interpreted as follows:

  • Wheel.bmp is followed by another basic texture. It is used as a standalone texture.
  • Wing.bmp is followed by another basic texture. It used as a standalone texture. It is declared as specular (S): as it has an alpha layer, it yields a specular effect.
  • Fuse.bmp is followed by a N texture and then by a L texture. These textures are automatically associated with the Fuse.bmp texture. At night, the Fuse_nm.bmp texture is replacing it. When the lights are on, it is superseded by the Fuse_lm.bmp texture. The Fuse.bmp texture is declared as specular (S), which is yielding a specular effect since the Fuse.bmp texture features an alpha layer.
  • Nose.bmp is followed by a N texture. This texture is automatically associated with the Nose.bmp texture. At night, the Nose_nm.bmp texture is replacing it. The Nose.bmp texture is declared as normal (A). It has an alpha layer and the alpha parameter is used to set the transparency.

Special effects
The following table gives a pitch of the most commonly used special effects. Other combinations may be implemented by setting the no shadow attribute of a textured sub-assy.

 sub-assy 
kind
 effect  material  texture
kind other attributes
colored normal color, no transparency,
no glare
  no texture
glaring effect color, no transparency,
glare effect and color
  no texture
transparency color, transparency,
no glare
  no texture
transparency
and glare
color, transparency,
glare effect and color
  no texture
textured normal color, shadow, no
glare
A
texture with no alpha layer
transparency
effect
color, no shadow, no
glare
A
texture with no alpha layer
normal
with holes
color, shadow, no
glare
A
texture with alpha layer
specular effect color, shadow, no
glare
S
texture with alpha layer
dedicated texture
at night
color, shadow, no
glare
A
N
texture with no alpha layer
night texture
normal with holes
dedicated texture
at night
color, shadow, no
glare
A
N
texture with alpha layer
night texture
specular effect
dedicated texture
at night
color, shadow, no
glare
S
N
texture with alpha layer
night texture
dedicated texture
when lit
color, shadow, no
glare
A
L
texture with no alpha layer
light texture
specular effect
dedicated texture
when lit
color, shadow, no
glare
S
L
texture with alpha layer
light texture
dedicated texture
at night and when lit
color, shadow, no
glare
A
N
L
texture with no alpha layer
night texture
light texture
specular effect
dedicated texture
at night and when lit
color, shadow, no
glare
S
N
L
texture with alpha layer
night texture
light texture


What to do with AD2K2...

AD2K2 handles textures and materials in the following way:

Texture list
The model texture list must be filled by you. You can do that by clicking on the button of the sub-assy panel or by clicking on the same button of the sub-assy code window. Any texture is associated with a fall-back color, which is the color to be used by the FS viewer if the texture is absent from the texture directory. It is also assigned a texture kind which is represented by a letter: The textures of the normal kind or of the specular kind may be assigned to a sub-assy. They are the basic kinds of texture. The night maps and the light maps are used by the FS viewer under special conditions (at night or when the aircraft lights are ON). They are associated with the first basic texture coming before in the list. They should not be directly assigned to a sub-assy.

Texture supports
The texture supports are simple polygons which you declare as texture support by simply selecting them on the graphic display window and activating the Utilities/Define as texture support menu option. AD2K2 keeps a list of them so that you can load any one of them from the texture support selection window. The texture supports are discussed in a dedicated section in this tutorial.

Colored sub-assy
To be displayed properly by the FS viewer, a sub-assy must be declared as textured or colored. When it is first created, the status of a sub-assy is undefined. If you do not assign a valid status to the sub-assy, it will not be displayed by the FS viewer.

To assign the color attribute to a sub-assy, select the color option in the combo-box of the sub-assy sub-panel in the sub-assy panel.

You need then to define the material associated with the sub-assy. Open the sub-assy code window by clicking on the button of the sub-assy panel. At the bottom of the window, the color sub-panel allows you to specify the attributes of the material:

Textured sub-assy
To assign a texture to a sub-assy, select the appropriate texture file in the combo-box of the sub-assy sub-panel in the sub-assy panel. The combo-box lists all the texture files available in the model texture list.

As it is explained in the previous section, you also need to define the material associated with the sub-assy. Open the sub-assy code window by clicking on the button of the sub-assy panel. At the bottom of the window, the color sub-panel allows you to specify the attributes of the material:

The shadow/no shadow option sets the transparency index of the material:

Texture declaration
The texture declaration is achieved through the texture selection panel. The texture selection panel can be launched either from the sub-assy panel or from the sub-assy code panel by clicking on the button on the tool bar. The texture selection panel allows you to load a new texture file, to discard a file already selected, to select the fallback color associated with a texture and to select the texture kind.
Texture kind: To select the texture kind, select the given texture in the texture file list and then the texture kind in the combo-box below. The following selection is available:

Giving the specular kind to a non-alpha texture has no effect on the display.
Fallback color: To select the texture fallback color associated to a texture, select the given texture in the texture file list and then double-click on the small color square in the sub-panel below the texture file list.

Tip: If the texture selection panel is launched from the sub-assy code panel, the texture which is selected when you exit the panel is automatically assigned to the currently selected sub-assy. If the texture selection panel is launched from the sub-assy panel, selecting a texture in the list and exiting the panel has no effect on the texture associated to the currently selected sub-assy.

Assigning a texture to a sub-assy

Caution: Do not assign a N texture or a L texture to a sub-assy.

Assigning a color to a sub-assy
In the sub-assy code panel, double-click on the small colored square at the bottom of the panel. A color palette is displayed. To select a color in the palette, click on it and validate. To create a new color, click on the new button to launch the color editor. To modify a color of the palette, click on it and then click on the modify button to launch the color editor. The palette just keeps the color actually used in the assembly (i.e associated to a sub-assy or to a LCOLOR instruction). A color which is not used is discarded from the palette.

Transparency and shadow
To give a certain level of transparency to a colored sub-assy, use the transparency up-down buttons at the bottom of the sub-assy code panel. The transparency control is turned into a shadow/no shadow control in case of textured sub-assy.

Glaring effect and reflected color
To set a glaring effect, check the glare check box at the bottom of the sub-assy code panel. When the glare check box is checked, a reflected color selection panel is displayed. Proceed as for the sub-assy color selection to set the reflected color.


Mapping a texture on a sub-assy: the whole process

item requirement
button
menu option
action from...
texture load the texture file in
the model texture list (1)
open the texture selection
window
sub-assy panel or
sub-assy code window
open
load the texture file texture selection window
colored
square
set fallback color texture selection window
combo-box
set texture kind texture selection window
associate the texture
with the sub-assy
select the sub-assy sub-assy panel
select the texture file sub-assy panel
material define the material
associated with the sub-assy
select the sub-assy sub-assy panel
open sub-assy code window sub-assy panel
left colored
square
select material color sub-assy code window
set shadow / transparency sub-assy code window
right colored
square
set glare effect
select reflected color
sub-assy code window
texture
support
define a texture support
as many times as needed (2)
select a chain graphic display window
Utilities/Define
as texture support
define the chain as texture
support
graphic display window
texture
limits
define texture limits
as many times as needed (3)
select the sub-assy sub-assy panel
open sub-assy code window sub-assy panel
select the LIMITS instruction
or the place to insert it
sub-assy code window
insert a new LIMITS instruction
(if needed)
sub-assy code window
open the texture limits window sub-assy code window
select the texture support
and orientation
texture support
selection window
limits
select the texture limits texture support
selection window

Click on...
Double-click on...
(1) If a night texture or a light texture is to be used, you just have to load it just after the basic texture it is associated with and declare it as a night map or a light map.
(2) Several texture supports can be used with the same sub-assy.
(3) A same sub-assy can be assigned several sets of texture support/texture limits.


copyright Hervé Devred 2003